<?php
namespace Admin\Form;

use UploadFile\Entity\Image as AvatarEntity;
use Zend\Form\Fieldset;
use Zend\InputFilter\InputFilterProviderInterface;
use Zend\Stdlib\Hydrator\ClassMethods;

class AvatarUserFieldset extends Fieldset  implements InputFilterProviderInterface
{
    public function __construct()
    {
        parent::__construct('avatar');

        $this
            ->setHydrator(new ClassMethods())
            ->setObject(new AvatarEntity())
        ;

        $file = new \Zend\Form\Element\File('image_path');
        $file
            ->setLabel('File Input')
            ->setAttributes(array(
                'id' => 'avatar',
                'class' => 'form-control col-xs-12',
                'placeholder' => 'avatar'
            ));
        $this->add($file);
    }

    /**
     * @return array
     */

    public function getInputFilterSpecification() {
        return array(
            'image_path' => array(
                'name'       => 'image_path',
                //'required'   => true,
                'filters' => array(
                    //array('name' => 'Library\Filter\File\Rename'),
                    array(
                        'name' => 'fileRenameUpload',
                        'options' => array(
                            'target' => './data/uploads/',
                            'overwrite' => true,
                            'randomize' => true,
                            'use_upload_name' => true
                        )
                    )
                ),
                /*'validators' => array(
                    array(
                        'name' => 'fileMimeType',
                        'options' => array(
                            'image',
                            'enableHeaderCheck' => true
                        )
                    )
                )*/
            )
        );
    }
} 